package com.mediacloud.app.newsmodule.view;

import android.content.Context;
import android.os.Build;
import androidx.annotation.RequiresApi;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.mediacloud.app.newsmodule.R;
import com.mediacloud.app.reslib.enums.AppFactoryGlobalConfig;

/**
 * Created by 陈凯 on 2017/9/21.
 */

public class TagView extends FrameLayout {

    Context mContext;

    public TagView(Context context) {
        super(context);

        initView();
    }

    TextView titles;
    TextView hasMore;

    public TagView(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView();
    }

    public TagView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView();
    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    public TagView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        initView();
    }

    private void initView() {
        mContext = getContext();

        LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);

        setLayoutParams(param);

        View view = LayoutInflater.from(mContext).inflate(R.layout.tagview, null);
        titles= view.findViewById(R.id.titles);
        hasMore= view.findViewById(R.id.hasMore);
        addView(view);
    }

    public void  onMoreClick(OnClickListener listener)
    {
        hasMore.setOnClickListener(listener);
    }

    public void setMoreVisibility(int  visibility)
    {

        hasMore.setVisibility(visibility);
    }
    public void  setTitles(String title)
    {

        if(title!=null)
        titles.setText(title);
    }

}